import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * @author caiwl
 * @date 2020/7/17 16:22
 */
public class Number {
    public static void main(String[] args) {
        String s1 = "2020-09-02 08:50:47";
        String s2 = "2020-09-02 18:30:47";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            // 这是时间差（毫秒）
            long time = sdf.parse(s2).getTime() - sdf.parse(s1).getTime();
            double hour = time / (60 * 60 * 1000.00);
            System.out.println("工时：" + String.format("%.2f", hour) + " h");
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
